<template>
    <div class="tech-blog">
        <div class="main">
            <div class="floating-elements">
                <div class="floating-square"></div>
                <div class="floating-square"></div>
                <div class="floating-square"></div>
                <div class="floating-circle"></div>
                <div class="floating-circle"></div>
                <div class="floating-circle"></div>
                <div class="floating-triangle"></div>
                <div class="floating-triangle"></div>
                <div class="floating-triangle"></div>
                <div class="floating-cross"></div>
                <div class="floating-cross"></div>
                <div class="floating-cross"></div>
            </div>
            <div class="light-beams">
                <div class="beam"></div>
                <div class="beam"></div>
                <div class="beam"></div>
            </div>
            <div class="container">
                <div class="nav-header">
                    <div class="left-section">
                        <router-link to="/home" class="back-link">
                            <svg class="back-icon" viewBox="0 0 24 24" width="24" height="24">
                                <path fill="currentColor"
                                    d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
                            </svg>
                            <span>首页</span>
                        </router-link>
                        <h1>技术博客</h1>
                    </div>

                    <!-- 搜索框移到右侧 -->
                    <div class="search-box cards">
                        <svg class="search-icon" viewBox="0 0 24 24" width="20" height="20">
                            <path fill="currentColor"
                                d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
                        </svg>
                        <input type="text" v-model="searchQuery" placeholder="搜索文章..." @input="handleSearch">
                        <button v-if="searchQuery" class="clear-btn" @click="clearSearch" title="清除搜索">
                            <svg viewBox="0 0 24 24" width="20" height="20">
                                <path fill="currentColor"
                                    d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
                            </svg>
                        </button>
                    </div>
                </div>

                <div class="categories cards">
                    <button class="category-btn" :class="{ active: selectedCategory === '' }"
                        @click="selectedCategory = ''">
                        全部
                    </button>
                    <button v-for="category in categories" :key="category" class="category-btn"
                        :class="{ active: selectedCategory === category }" @click="selectedCategory = category">
                        {{ category }}
                    </button>
                </div>

                <div class="blog-list" v-loading="loading">
                    <article v-for="post in paginatedPosts" :key="post.id" class="blog-item cards"
                        @click="goToDetail(post.id)">
                        <h2>{{ post.title }}</h2>
                        <div class="meta">
                            <span class="date">{{ post.date }}</span>
                            <span class="author">
                                <svg class="author-icon" viewBox="0 0 24 24" width="16" height="16">
                                    <path fill="currentColor"
                                        d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" />
                                </svg>
                                {{ post.author }}
                            </span>
                        </div>
                        <p class="summary">{{ post.summary }}</p>
                        <div class="tags">
                            <span v-for="tag in post.tags" :key="tag" class="tag">{{ tag }}</span>
                        </div>
                    </article>
                </div>

                <div class="pagination cards" v-if="totalPages > 1">
                    <button class="page-btn" :disabled="currentPage === 1" @click="currentPage--">
                        上一页
                    </button>
                    <div class="page-numbers">
                        <button v-for="page in displayedPages" :key="page" class="page-btn"
                            :class="{ active: currentPage === page }" @click="currentPage = page">
                            {{ page }}
                        </button>
                    </div>
                    <button class="page-btn" :disabled="currentPage === totalPages" @click="currentPage++">
                        下一页
                    </button>
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { ref, computed, watch, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import request from '@/utils/requestLogin'
import { ElMessage } from 'element-plus'

const router = useRouter()
const selectedCategory = ref('')
const currentPage = ref(1)
const postsPerPage = 10
const loading = ref(false)

// 首先定义接口
interface ArticleDisplay {
    id: number
    title: string
    date: string
    author: string
    summary: string
    tags: string[]
}

// 文章列表数据
const posts = ref<ArticleDisplay[]>([])
const total = ref(0)
const categories = ref<string[]>([])

// 添加分页显示逻辑
const displayedPages = computed(() => {
    const pages = []
    const maxDisplayed = 5 // 最多显示5个页码
    let start = Math.max(1, currentPage.value - 2)
    let end = Math.min(totalPages.value, start + maxDisplayed - 1)

    if (end - start + 1 < maxDisplayed) {
        start = Math.max(1, end - maxDisplayed + 1)
    }

    for (let i = start; i <= end; i++) {
        pages.push(i)
    }
    return pages
})

// 修改获取文章列表的方法
const fetchArticles = async () => {
    loading.value = true
    try {
        const params = {
            page: currentPage.value,
            pageSize: postsPerPage,
            title: searchQuery.value || undefined,
            status: 'published'
        }

        const response = await request.get('http://cylyxsz.w1.luyouxia.net/blog/api/articles/tech', { params })

        if (response.code === 200 && response.data) {
            // 处理文章列表数据
            posts.value = response.data.list.map((article: any) => ({
                id: article.id,
                title: article.title,
                date: new Date(article.createTime).toLocaleDateString(),
                author: article.author || '匿名',
                summary: article.summary || (article.content ? article.content.slice(0, 100) + '...' : '暂无简介'),
                tags: article.tags ? JSON.parse(article.tags) : []
            }))

            total.value = response.data.total

            // 从所有文章的标签中提取分类
            const allTags = posts.value.reduce((acc: string[], post) => {
                return acc.concat(post.tags)
            }, [])
            
            // 去重并更新分类列表
            categories.value = Array.from(new Set(allTags))
        } else {
            ElMessage.error(response.message || '获取文章列表失败')
        }
    } catch (error) {
        console.error('获取文章列表失败:', error)
        ElMessage.error('获取文章列表失败')
    } finally {
        loading.value = false
    }
}

// 修改过滤逻辑
const filteredPosts = computed(() => {
    if (!selectedCategory.value) {
        return posts.value
    }
    return posts.value.filter(post => post.tags.includes(selectedCategory.value))
})

// 修改分页逻辑
const paginatedPosts = computed(() => {
    const start = (currentPage.value - 1) * postsPerPage
    const end = start + postsPerPage
    return filteredPosts.value.slice(start, end)
})

// 修改总页数计算
const totalPages = computed(() => {
    return Math.ceil(filteredPosts.value.length / postsPerPage)
})

// 移除分类变化的监听，只保留页码变化的监听
watch([currentPage], () => {
    if (currentPage.value > totalPages.value) {
        currentPage.value = 1
    }
})

// 搜索相关
const searchQuery = ref('')
const handleSearch = () => {
    currentPage.value = 1
    fetchArticles()
}

const clearSearch = () => {
    searchQuery.value = ''
    currentPage.value = 1
    fetchArticles()
}

// 跳转到文章详情
const goToDetail = (id: number) => {
    router.push(`/tech/${id}`)
}

// 页面加载时获取数据
onMounted(() => {
    fetchArticles()
})
</script>

<style scoped>
.tech-blog {
    min-height: 100vh;
    position: relative;
    background:
        linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%),
        radial-gradient(circle at 50% -20%, rgba(91, 37, 195, 0.15) 0%, transparent 70%),
        radial-gradient(circle at 0% 80%, rgba(41, 125, 182, 0.1) 0%, transparent 50%);
    overflow-y: auto;
    animation: gradientMove 15s ease infinite;
}

.main {
    position: relative;
    color: #fff;
    min-height: 100vh;
    padding-bottom: 2rem;
    background:
        radial-gradient(circle at 10% 20%, rgba(91, 37, 195, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(41, 125, 182, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 60%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    overflow: hidden;
}

.main::before,
.main::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: floatBubble 20s infinite;
    pointer-events: none;
}

.main::before {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    top: -100px;
    left: -100px;
    animation-delay: -5s;
}

.main::after {
    background: linear-gradient(45deg, #45b8ac, #7b68ee);
    bottom: -100px;
    right: -100px;
    animation-duration: 25s;
}

@keyframes floatBubble {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(100px, 50px) rotate(90deg);
    }

    50% {
        transform: translate(50px, 100px) rotate(180deg);
    }

    75% {
        transform: translate(-50px, 50px) rotate(270deg);
    }
}

.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* 两端对齐 */
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
}

.left-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.back-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateX(-5px);
}

.back-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.nav-header h1 {
    font-size: 2rem;
    margin: 0;
}

.categories {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.category-btn {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.category-btn:hover {
    background: linear-gradient(to right, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border-color: rgba(255, 255, 255, 0.2);
}

.category-btn.active {
    background: linear-gradient(to right, rgba(91, 37, 195, 0.3), rgba(41, 125, 182, 0.3));
    border-color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

.container {
    position: relative;
    z-index: 3;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    height: auto;
}

.cards {
    background: linear-gradient(145deg,
            rgba(255, 255, 255, 0.08) 0%,
            rgba(255, 255, 255, 0.05) 100%);
    border-radius: 12px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.08),
        inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.cards:hover {
    transform: translateY(-2px) scale(1.01);
    background: linear-gradient(145deg,
            rgba(255, 255, 255, 0.12) 0%,
            rgba(255, 255, 255, 0.08) 100%);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow:
        0 8px 12px rgba(0, 0, 0, 0.15),
        0 3px 6px rgba(0, 0, 0, 0.1),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

.page-header {
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    animation: fade .5s;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.blog-list {
    display: grid;
    gap: 1.5rem;
    animation: fade .5s;
    height: auto;
    min-height: 0;
}

.blog-item {
    padding: 1.5rem;
    cursor: pointer;
    height: auto;
    animation: fadeIn 0.6s ease-out;
    animation-fill-mode: both;
}

.blog-item:nth-child(odd) {
    animation-delay: 0.1s;
}

.blog-item:nth-child(even) {
    animation-delay: 0.2s;
}

.blog-item h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.meta {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    opacity: 0.8;
    align-items: center;
}

.author {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.author-icon {
    opacity: 0.7;
}

.summary {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    background: linear-gradient(135deg,
            rgba(91, 37, 195, 0.15) 0%,
            rgba(41, 125, 182, 0.15) 100%);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
}

.tag:hover {
    background: linear-gradient(135deg,
            rgba(91, 37, 195, 0.25) 0%,
            rgba(41, 125, 182, 0.25) 100%);
    transform: translateY(-1px);
}

@keyframes fade {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@media (max-width: 768px) {
    .back-button {
        top: 1rem;
        left: 1rem;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .categories {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .category-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .container {
        padding-top: 4rem;
    }
}

.pagination {
    margin-top: 2rem;
    padding: 1rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    align-items: center;
}

.page-numbers {
    display: flex;
    gap: 0.5rem;
}

.page-btn {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn:hover:not(:disabled) {
    background: linear-gradient(to right, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border-color: rgba(255, 255, 255, 0.2);
}

.page-btn.active {
    background: linear-gradient(to right, rgba(91, 37, 195, 0.3), rgba(41, 125, 182, 0.3));
    border-color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

/* 添加浮动元素样式 */
.floating-elements {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: hidden;
}

.floating-square,
.floating-circle,
.floating-triangle,
.floating-cross {
    position: absolute;
    opacity: 0.15;
    filter: blur(1px);
    animation: float 20s infinite linear;
    z-index: 1;
}

/* 增加更多方形元素 */
.floating-square:nth-child(1) {
    width: 40px;
    height: 40px;
    background: linear-gradient(45deg, rgba(255, 107, 107, 0.4), rgba(78, 205, 196, 0.4));
    top: 15%;
    left: 10%;
    animation-delay: -5s;
}

.floating-square:nth-child(2) {
    width: 30px;
    height: 30px;
    background: linear-gradient(45deg, rgba(123, 104, 238, 0.4), rgba(69, 184, 172, 0.4));
    top: 45%;
    right: 15%;
    animation-delay: -8s;
}

.floating-square:nth-child(3) {
    width: 25px;
    height: 25px;
    background: linear-gradient(45deg, rgba(78, 205, 196, 0.4), rgba(255, 107, 107, 0.4));
    bottom: 25%;
    left: 20%;
    animation-delay: -12s;
}

/* 增加更多圆形元素 */
.floating-circle:nth-child(1) {
    width: 50px;
    height: 50px;
    background: linear-gradient(45deg, rgba(69, 184, 172, 0.4), rgba(123, 104, 238, 0.4));
    border-radius: 50%;
    top: 30%;
    right: 25%;
    animation-delay: -3s;
}

.floating-circle:nth-child(2) {
    width: 35px;
    height: 35px;
    background: linear-gradient(45deg, rgba(123, 104, 238, 0.4), rgba(255, 107, 107, 0.4));
    border-radius: 50%;
    bottom: 35%;
    right: 40%;
    animation-delay: -7s;
}

.floating-circle:nth-child(3) {
    width: 45px;
    height: 45px;
    background: linear-gradient(45deg, rgba(255, 107, 107, 0.4), rgba(69, 184, 172, 0.4));
    border-radius: 50%;
    top: 60%;
    left: 35%;
    animation-delay: -10s;
}

/* 增加更多三角形元素 */
.floating-triangle:nth-child(1) {
    border-left: 25px solid transparent;
    border-right: 25px solid transparent;
    border-bottom: 43px solid rgba(255, 255, 255, 0.3);
    top: 25%;
    right: 30%;
    animation-delay: -4s;
}

.floating-triangle:nth-child(2) {
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 35px solid rgba(255, 255, 255, 0.15);
    bottom: 30%;
    left: 25%;
    animation-delay: -9s;
}

.floating-triangle:nth-child(3) {
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 26px solid rgba(255, 255, 255, 0.1);
    top: 55%;
    right: 15%;
    animation-delay: -14s;
}

/* 增加更多十字形元素 */
.floating-cross:nth-child(1) {
    width: 30px;
    height: 30px;
    background: linear-gradient(45deg, rgba(255, 107, 107, 0.4), rgba(123, 104, 238, 0.4));
    transform: rotate(45deg);
    top: 40%;
    left: 15%;
    animation-delay: -6s;
}

.floating-cross:nth-child(2) {
    width: 25px;
    height: 25px;
    background: linear-gradient(45deg, rgba(69, 184, 172, 0.4), rgba(255, 107, 107, 0.4));
    transform: rotate(45deg);
    bottom: 20%;
    right: 20%;
    animation-delay: -11s;
}

.floating-cross:nth-child(3) {
    width: 35px;
    height: 35px;
    background: linear-gradient(45deg, rgba(123, 104, 238, 0.4), rgba(78, 205, 196, 0.4));
    transform: rotate(45deg);
    top: 70%;
    left: 30%;
    animation-delay: -15s;
}

/* 添加光束效果 */
.light-beams {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.beam {
    position: absolute;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(255, 255, 255, 0.1) 50%,
            transparent 100%);
    animation: moveBeam 8s infinite linear;
    opacity: 0.2;
}

.beam:nth-child(1) {
    left: 20%;
    animation-delay: -2s;
}

.beam:nth-child(2) {
    left: 50%;
    animation-delay: -4s;
}

.beam:nth-child(3) {
    left: 80%;
    animation-delay: -6s;
}

/* 添加画关键帧 */
@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(50px, 25px) rotate(90deg);
    }

    50% {
        transform: translate(25px, 50px) rotate(180deg);
    }

    75% {
        transform: translate(-25px, 25px) rotate(270deg);
    }

    100% {
        transform: translate(0, 0) rotate(360deg);
    }
}

@keyframes moveBeam {
    0% {
        transform: translateX(-100px) rotate(45deg);
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: translateX(100px) rotate(45deg);
        opacity: 0;
    }
}

/* 修改 container 样式确保内容在动态元素上层 */
.container {
    position: relative;
    z-index: 2;
    /* 其他样式保持不变 */
}

/* 优化光点效果 */
.main .light-dots {
    background-size: 60px 60px;
    opacity: 0.3;
    animation: twinkle 4s infinite ease-in-out;
    z-index: 1;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.2;
    }

    50% {
        opacity: 0.4;
    }
}

/* 修改浮动元素的础样式 */
.floating-square,
.floating-circle,
.floating-triangle,
.floating-cross {
    position: absolute;
    opacity: 0.15;
    filter: blur(1px);
    animation: float 20s infinite linear;
    z-index: 1;
}

/* 修改 container 的层级 */
.container {
    position: relative;
    z-index: 3;
    /* 其他样式保持不变 */
}

/* 修改光束效果 */
.light-beams {
    z-index: 1;
}

.beam {
    opacity: 0.2;
    width: 3px;
}

/* 修改光点效果 */
.main .light-dots {
    z-index: 1;
    opacity: 0.4;
}

/* 改背景渐变元素 */
.main::before,
.main::after {
    opacity: 0.2;
    z-index: 1;
}

/* 调整浮动元素的颜色，使其更明显 */
.floating-square:nth-child(1) {
    background: linear-gradient(45deg, rgba(255, 107, 107, 0.4), rgba(78, 205, 196, 0.4));
}

.floating-square:nth-child(2) {
    background: linear-gradient(45deg, rgba(123, 104, 238, 0.4), rgba(69, 184, 172, 0.4));
}

.floating-square:nth-child(3) {
    background: linear-gradient(45deg, rgba(78, 205, 196, 0.4), rgba(255, 107, 107, 0.4));
}

.floating-circle:nth-child(1) {
    background: linear-gradient(45deg, rgba(69, 184, 172, 0.4), rgba(123, 104, 238, 0.4));
}

.floating-circle:nth-child(2) {
    background: linear-gradient(45deg, rgba(123, 104, 238, 0.4), rgba(255, 107, 107, 0.4));
}

.floating-circle:nth-child(3) {
    background: linear-gradient(45deg, rgba(255, 107, 107, 0.4), rgba(69, 184, 172, 0.4));
}

.floating-triangle:nth-child(1),
.floating-triangle:nth-child(2),
.floating-triangle:nth-child(3) {
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.floating-cross:nth-child(1) {
    background: linear-gradient(45deg, rgba(255, 107, 107, 0.4), rgba(123, 104, 238, 0.4));
}

.floating-cross:nth-child(2) {
    background: linear-gradient(45deg, rgba(69, 184, 172, 0.4), rgba(255, 107, 107, 0.4));
}

.floating-cross:nth-child(3) {
    background: linear-gradient(45deg, rgba(123, 104, 238, 0.4), rgba(78, 205, 196, 0.4));
}

/* 调整动画速度，使其更容易观察 */
@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(50px, 25px) rotate(90deg);
    }

    50% {
        transform: translate(25px, 50px) rotate(180deg);
    }

    75% {
        transform: translate(-25px, 25px) rotate(270deg);
    }

    100% {
        transform: translate(0, 0) rotate(360deg);
    }
}

/* 修改媒体查询部分 */
@media (max-width: 768px) {

    /* 导航头部 */
    .nav-header {
        padding: 1rem 0.5rem;
    }

    .nav-header h1 {
        font-size: 1.8rem;
        /* 调大标题字体 */
    }

    .back-link {
        padding: 0.6rem 1.2rem;
        /* 增大点击区域 */
        font-size: 1rem;
        /* 增大字体 */
    }

    .back-icon {
        width: 1.8rem;
        /* 增大图标 */
        height: 1.8rem;
    }

    /* 分类按钮 */
    .categories {
        padding: 1rem 0.5rem;
        gap: 0.8rem;
    }

    .category-btn {
        padding: 0.6rem 1.2rem;
        /* 增大按钮 */
        font-size: 1rem;
        /* 增大字体 */
    }

    /* 文章列表 */
    .blog-item {
        padding: 1.2rem;
    }

    .blog-item h2 {
        font-size: 1.3rem;
        line-height: 1.4;
    }

    .meta {
        font-size: 1rem;
        /* 增大元信息字体 */
        gap: 1rem;
        flex-wrap: wrap;
        /* 允许换行 */
    }

    .summary {
        font-size: 1rem;
        line-height: 1.6;
    }

    .tags {
        gap: 0.8rem;
    }

    .tag {
        padding: 0.4rem 1rem;
        /* 增大标签 */
        font-size: 0.95rem;
        /* 增大字体 */
    }

    /* 分页 */
    .pagination {
        padding: 1.2rem 0.5rem;
        gap: 0.8rem;
    }

    .page-btn {
        padding: 0.8rem 1.5rem;
        /* 显著增大分页按钮 */
        font-size: 1.1rem;
        /* 增大字体 */
    }

    .page-numbers {
        gap: 0.8rem;
    }

    /* 容器padding */
    .container {
        padding: 1rem 0.8rem;
    }

    /* 调整文章列表间距 */
    .blog-list {
        gap: 1rem;
    }
}

/* 添加小屏幕的特殊处理 */
@media (max-width: 480px) {
    .nav-header h1 {
        font-size: 1.6rem;
    }

    .meta {
        gap: 0.8rem;
    }

    /* 在超小屏幕上隐藏部分页码 */
    .page-numbers button:not(.active) {
        display: none;
    }

    .page-numbers button.active {
        display: inline-block;
    }

    /* 确保"上一页"和"下一页"按钮始终显示 */
    .pagination>.page-btn {
        display: inline-block;
    }
}

/* 添加横屏模式的优化 */
@media (max-width: 896px) and (orientation: landscape) {
    .container {
        padding: 1rem;
    }

    .blog-list {
        gap: 1rem;
    }

    .blog-item {
        padding: 1rem;
    }
}

/* 添加搜索框样式 */
.search-box {
    width: 300px;
    /* 固定宽度 */
    padding: 0.5rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: linear-gradient(145deg,
            rgba(255, 255, 255, 0.08) 0%,
            rgba(255, 255, 255, 0.05) 100%);
    transition: all 0.3s ease;
}

.search-box:focus-within {
    width: 400px;
    /* 聚焦时扩大宽度 */
    background: linear-gradient(145deg,
            rgba(255, 255, 255, 0.12) 0%,
            rgba(255, 255, 255, 0.08) 100%);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .nav-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
        /* 移动端全宽 */
    }

    .search-box:focus-within {
        width: 100%;
    }

    .left-section {
        justify-content: space-between;
        margin-bottom: 1rem;
    }
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    outline: none;
    padding: 0.5rem 0;
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-icon {
    opacity: 0.7;
}

.clear-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}
</style>